package cn.com.visual.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import org.springframework.stereotype.Controller;

import cn.com.common.result.DataResult;

import cn.com.gt3.entity.GtDjxxEntity;
import cn.com.gt3.entity.GtFpJxEntity;
import cn.com.gt3.entity.GtFpXxEntity;
import cn.com.gt3.entity.GtRkEntity;
import cn.com.gt3.entity.GtSbXgmEntity;
import cn.com.gt3.entity.GtSbYbrEntity;
import cn.com.gt3.service.GtDjxxService;
import cn.com.gt3.service.GtFpJxService;
import cn.com.gt3.service.GtFpXxService;
import cn.com.gt3.service.GtRkService;
import cn.com.gt3.service.GtSbXgmService;
import cn.com.gt3.service.GtSbYbrService;
import cn.com.nr.entity.NrOfflineCamEntity;
import cn.com.nr.entity.NrRecordsEntity;
import cn.com.nr.service.NrOfflineCamService;
import cn.com.nr.service.NrRecordsService;
import io.swagger.annotations.ApiOperation;

import java.text.ParseException;


/**
 * 首页
 *
 * @author shaochangyang
 * @email l2l84o7o5@live.com
 * @date 2024-03-24 01:14:06
 */
@Controller
@RequestMapping("/visual/table")
public class VisualTableMainController {

	@Autowired
	private NrRecordsService nrRecordsService;

	@Autowired
	private NrOfflineCamService nrOfflineCamService;

	@Autowired
	private GtDjxxService gtDjxxService;
	
	@Autowired
	private GtFpJxService gtFpJxService;
	
	@Autowired
	private GtFpXxService gtFpXxService;
	
	@Autowired
	private GtRkService gtRkService;
	
	@Autowired
	private GtSbXgmService gtSbXgmService;
	
	@Autowired
	private GtSbYbrService gtSbYbrService;
	
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@ApiOperation(value = "nsrcx")
	@PostMapping("/nsrcx")
	@ResponseBody
	public DataResult nsrcx(@RequestBody GtDjxxEntity gtDjxxEntity) {
		
		Page page = new Page(gtDjxxEntity.getPage(), gtDjxxEntity.getLimit());
		
		LambdaQueryWrapper<GtDjxxEntity> queryWrapper = Wrappers.lambdaQuery();


		IPage<GtDjxxEntity> iPage = gtDjxxService.page(page, queryWrapper);
		
		return DataResult.success(iPage);
		
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "djxx")
	@PostMapping("/djxx")
	@ResponseBody
	public DataResult djxx(@RequestBody GtDjxxEntity gtDjxxEntity) throws ParseException {

		Page page = new Page(gtDjxxEntity.getPage(), gtDjxxEntity.getLimit());
		
		LambdaQueryWrapper<GtDjxxEntity> queryWrapper = Wrappers.lambdaQuery();


		IPage<GtDjxxEntity> iPage = gtDjxxService.page(page, queryWrapper);
		
		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "sbxxYbr")
	@PostMapping("/sbxxYbr")
	@ResponseBody
	public DataResult sbxxYbr(@RequestBody GtSbYbrEntity gtSbYbrEntity) throws ParseException {
		Page page = new Page(gtSbYbrEntity.getPage(), gtSbYbrEntity.getLimit());
		LambdaQueryWrapper<GtSbYbrEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<GtSbYbrEntity> iPage = gtSbYbrService.page(page, queryWrapper);
		return DataResult.success(iPage);
		
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "sbxxXgm")
	@PostMapping("/sbxxXgm")
	@ResponseBody
	public DataResult sbxxXgm(@RequestBody GtSbXgmEntity gtSbXgmEntity) throws ParseException {

		Page page = new Page(gtSbXgmEntity.getPage(), gtSbXgmEntity.getLimit());
		LambdaQueryWrapper<GtSbXgmEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<GtSbYbrEntity> iPage = gtSbXgmService.page(page, queryWrapper);
		return DataResult.success(iPage);
		
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "rkxx")
	@PostMapping("/rkxx")
	@ResponseBody
	public DataResult rkxx(@RequestBody GtRkEntity gtRkEntity) throws ParseException {
		Page page = new Page(gtRkEntity.getPage(), gtRkEntity.getLimit());
		LambdaQueryWrapper<GtRkEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<GtRkEntity> iPage = gtRkService.page(page, queryWrapper);
		return DataResult.success(iPage);
	}
	
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "fpxxJx")
	@PostMapping("/fpxxJx")
	@ResponseBody
	public DataResult fpxxJx(@RequestBody GtFpJxEntity gtFpJxEntity) throws ParseException {

		Page page = new Page(gtFpJxEntity.getPage(), gtFpJxEntity.getLimit());
		LambdaQueryWrapper<GtFpJxEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<GtFpJxEntity> iPage = gtFpJxService.page(page, queryWrapper);
		return DataResult.success(iPage);
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "fpxxXx")
	@PostMapping("/fpxxXx")
	@ResponseBody
	public DataResult fpxxXx(@RequestBody GtFpXxEntity gtFpXxEntity) throws ParseException {
		Page page = new Page(gtFpXxEntity.getPage(), gtFpXxEntity.getLimit());
		LambdaQueryWrapper<GtFpXxEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<GtFpXxEntity> iPage = gtFpXxService.page(page, queryWrapper);
		return DataResult.success(iPage);
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "cljl")
	@PostMapping("/cljl")
	@ResponseBody
	public DataResult cljl(@RequestBody NrRecordsEntity nrRecords) throws ParseException {

		Page page = new Page(nrRecords.getPage(), nrRecords.getLimit());
		LambdaQueryWrapper<NrRecordsEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<NrRecordsEntity> iPage = nrRecordsService.page(page, queryWrapper);
		
		return DataResult.success(iPage);
	}
	
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@ApiOperation(value = "yjxx")
	@PostMapping("/yjxx")
	@ResponseBody
	public DataResult yjxx(@RequestBody NrOfflineCamEntity nrOfflineCam) throws ParseException {

		Page page = new Page(nrOfflineCam.getPage(), nrOfflineCam.getLimit());
		LambdaQueryWrapper<NrOfflineCamEntity> queryWrapper = Wrappers.lambdaQuery();
		IPage<NrOfflineCamEntity> iPage = nrOfflineCamService.page(page, queryWrapper);
		
		return DataResult.success(iPage);
		
	}
	
	
	
	private static String handleMonthYear(int month, int year) {
		if (month <= 9) {
			return year + "0" + month;
		} else {
			return year + "" + month;
		}
	}

}
